﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using EntityObject;
using SharedLibraries;
using ThangNM_LIB.FUNC;
using ThangNM_LIB.EO;

namespace DataAccessObject
{
    public class SEODAO : DB_SQL_EXT
    {
        //public static Boolean Insert(SEOEO _SEOEO)
        //{
        //    SqlCommand cmd = new SqlCommand("Sitemap_Insert", connMSSql);
        //    cmd.CommandType = CommandType.StoredProcedure;
        //    cmd.Parameters.Add(new SqlParameter("@loc", _SEOEO.loc));
        //    cmd.Parameters.Add(new SqlParameter("@lastmod", _SEOEO.lastmod));
        //    cmd.Parameters.Add(new SqlParameter("@changefreq", _SEOEO.changefreq));
        //    cmd.Parameters.Add(new SqlParameter("@priority", _SEOEO.priority));
        //    cmd.Parameters.Add(new SqlParameter("@type", _SEOEO.type));
        //    cmd.Parameters.Add(new SqlParameter("@status", _SEOEO.status));
        //    ExecuteNonQuery(cmd);
        //    return true;
        //}

        //public static Boolean Update(SEOEO _SEOEO)
        //{
        //    SqlCommand cmd = new SqlCommand("Sitemap_Update", connMSSql);
        //    cmd.CommandType = CommandType.StoredProcedure;
        //    cmd.Parameters.Add(new SqlParameter("@loc", _SEOEO.loc));
        //    cmd.Parameters.Add(new SqlParameter("@lastmod", _SEOEO.lastmod));
        //    cmd.Parameters.Add(new SqlParameter("@changefreq", _SEOEO.changefreq));
        //    cmd.Parameters.Add(new SqlParameter("@priority", _SEOEO.priority));
        //    cmd.Parameters.Add(new SqlParameter("@type", _SEOEO.type));
        //    cmd.Parameters.Add(new SqlParameter("@status", _SEOEO.status));
        //    ExecuteNonQuery(cmd);
        //    return true;
        //}

        public Boolean Update_iComment_iVisit_iLike(SEO_EXEO _SEO_EXEO)
        {
            SqlCommand cmd = new SqlCommand("SEO_Update_iComment_iVisit_iLike");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@PK_iTable", _SEO_EXEO.PK_iTable));
            cmd.Parameters.Add(new SqlParameter("@PK_iSEO", _SEO_EXEO.PK_iSEO));
            cmd.Parameters.Add(new SqlParameter("@iComment_iLike", _SEO_EXEO.iComment_iLike));
            cmd.Parameters.Add(new SqlParameter("@iComment_iVisit_iLike", _SEO_EXEO.iComment_iVisit_iLike));
            return ExecuteNonQuery_RetBool(cmd);
        }

        public DataTable SelectBy_Status(Boolean _bStatus)
        {
            SqlCommand cmd = new SqlCommand("SEO_SelectBy_Status");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@bStatus", _bStatus));
            return GetDataTable(cmd);
        }

        public DataTable SelectList()
        {
            SqlCommand cmd = new SqlCommand("SEO_SelectList");
            cmd.CommandType = CommandType.StoredProcedure;
            return GetDataTable(cmd);
        }

        public SEOEO SEODO(DataTable input)
        {
            List<SEOEO> lst = new List<SEOEO>();
            lst = (List<SEOEO>)ConvertEx.ConvertDataTableToListObject<SEOEO>(input, lst.GetType());
            if (CommonsCheck.ListObject_OK(lst))
                return lst[0];
            else
                return null;
        }
    }
}